﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.ComponentModel;

namespace CustomControl
{
    public class TestControl : Control
    {
        private string name = "姓名：";

        /// <summary>
        /// 修改或者得到文本姓名的显示值
        /// </summary>
        [Description("修改或者得到文本姓名的显示值")]
        [Browsable(true)]
        public virtual string Name
        {
            get { return name; }
            set { name = value; }
        }

        private string showname = "显示";

        /// <summary>
        /// 修改或者得到按钮显示的显示值
        /// </summary>
        [Description("修改或者得到按钮显示的显示值")]
        [Browsable(true)]
        public virtual string ShowName
        {
            get { return showname; }
            set { showname = value; }
        }

        protected override void Render(HtmlTextWriter writer)
        {
            writer.Write("<table border=\"1\" cellpadding=\"2\" cellspacing=\"3\">");
            writer.Write("<tr>");
            writer.Write("<td>");
            writer.Write("姓名：");
            writer.Write("</td>");
            writer.Write("<td>");
            writer.Write("<input id=\"Txt_Name\" type=\"text\" name=\"Txt_Name\" />");
            writer.Write("</td>");
            writer.Write("</tr>");
            writer.Write("<tr>");
            writer.Write("<td colspan=\"2\" align=\"center\">");
            writer.Write("<input id=\"Txt_Show\" type=\"submit\" value=\"" + ShowName + "\" name=\"Txt_Show\" />");
            writer.Write("</td>");
            writer.Write("</tr>");
            writer.Write("</table>");
            base.Render(writer);
        }
    }
}